﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WMS.API.Application.Command.StocktakingManagement.PendingOrder;
using WMS.Domain.Entities.StocktakingManagement;
using WMS.ErrorCode;

namespace WMS.API.Controllers.StocktakingManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PendingOrdersController : ControllerBase
    {
        private readonly IMediator _mediator;

        public PendingOrdersController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 新增待盘点订单-xzc
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddPendingOrders(AddPendingOrdersCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 查询待盘点订单-xzc
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<PendingOrders>>> QueryPendingOrders([FromQuery]QueryPendingOrdersCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 更新待盘点订单-xzc
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]  
        public async Task<APIResult<int>> UpdatePendingOrders(UpdatePendingOrdersCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 删除待盘点订单-xzc
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DeletePendingOrders(DeletePendingOrdersCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 反填待盘点订单-xzc
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<PendingOrders>>> FindPendingOrders([FromQuery]FindPendingOrdersCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 批量删除待盘点订单-xzc
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DeletePendingOrdersAnage(DeletePendingAnageOrdersCommand request)
        {
            return await _mediator.Send(request);
        }
    }
}
